package com.lej.my.collect

import androidx.appcompat.widget.AppCompatImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.lej.core.utils.load
import com.lej.dataservice.club.bean.main.my.MyCollectInfo
import com.lej.my.R

/**
 *  author: cjq
 *  date  : 2022/6/12 0012
 *  desc  :
 */
class MyCollectAdapter(resId: Int) : BaseQuickAdapter<MyCollectInfo, BaseViewHolder>(resId),
    LoadMoreModule {
    override fun convert(holder: BaseViewHolder, item: MyCollectInfo) {
        val iv = holder.getView<AppCompatImageView>(R.id.iv_icon)
//        iv.load(item.image, R.drawable.ic_load_place, R.drawable.ic_load_place_error, callBack = {
//            if (it.intrinsicWidth > it.intrinsicHeight) {
//                iv.layoutParams.width = ConstraintLayout.LayoutParams.MATCH_PARENT
//            } else {
//                iv.layoutParams.height = ConstraintLayout.LayoutParams.MATCH_PARENT
//            }
//            iv.dimensionRatio("w,${it.intrinsicWidth}:${it.intrinsicHeight}")
//        })
        load(item.image,R.drawable.ic_load_place,R.drawable.ic_load_place_error,iv)
        holder.setText(R.id.tv_title, item.name)
        holder.setText(R.id.tv_label, item.number)
        holder.setVisible(R.id.iv_equity, item.have_rights == 1 && !item.isTrans())
        holder.setVisible(R.id.tv_equity, item.have_rights == 1 && !item.isTrans())
        holder.setVisible(R.id.tv_trans,item.isTrans())

        holder.setText(R.id.tv_equity, item.rights)
    }
}